﻿using Serilog;
using Serilog.Events;
using System;

namespace SerilogThreadIdEnricher
{
    class Program
    {
        private static void CreateLog()
        {
            // 配置 Serilog 
            Log.Logger = new LoggerConfiguration()
                .Enrich.FromLogContext()
                .Enrich.With<ThreadIdEnricher>()
                // 配置日志输出到控制台
                .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{ThreadId}] {Message:lj}{NewLine}{Exception}")
                // 创建 logger
                .CreateLogger();
        }
        static void Main(string[] args)
        {
            CreateLog();
            Log.Logger.Information("Hello World!");
            Console.ReadLine();
        }
    }
}
